package com.zyit.web;

import com.zyit.entity.T_base_order;
import com.zyit.entity.T_goods;
import com.zyit.service.Impl.OrderListServiceImpl;
import com.zyit.service.OrderListService;
import com.zyit.util.Page;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/list")
public class OrderListServlet extends HttpServlet {
    private OrderListService orderListService = new OrderListServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
       // List<T_goods> t_base_orderList = orderListService.findAll();
      //  request.setAttribute("t_base_orderList",t_base_orderList);
        String pageNo = request.getParameter("pageNo");
        Integer currPage = 1;
        try {
            currPage = Integer.valueOf(pageNo);
        }catch (NumberFormatException e){
            e.printStackTrace();
        }
        List<T_goods> t_goodsPage = orderListService.findByPage();
        HttpSession session = request.getSession();
        session.setAttribute("t_goodsPage",t_goodsPage);


        Page<T_base_order> base_orders = orderListService.findOrderNo(currPage);
        HttpSession session1 = request.getSession();
        session1.setAttribute("base_orders",base_orders);
        request.getRequestDispatcher("manager/order/orderInfoList.jsp").forward(request,response);


    }


}
